<template>
  <div id="app">
    <v-header :seller="seller"></v-header>
    <div class="tab border-1px">
      <router-link to="/goods"  class="tab-item">商品</router-link>
      <router-link to="/ratings"   class="tab-item">评论</router-link>
      <router-link to="/seller"  class="tab-item">商家</router-link>
    </div>
    <router-view :seller="seller"></router-view>
  </div>
</template>

<script type="text/ecmascript-6">
  import Header from '@/components/header/MyHeader.vue'
  import Tab from '@/components/tab/MyTab'
  const ERR_OK = 0
export default {
  data () {
    return {
       seller: {}
    }
  },
  created() {
    //在url里加入参数id可以区分不同商家的数据，返回不同的seller数据
    this.$http.get('/api/seller').then((response) => {
      response = response.body
      if (response.errno === ERR_OK) {
        this.seller = response.data
        console.log(response)
        //给this.seller扩展属性，保留id属性
        //this.seller = Object.assign({}, this.seller, response.data);
      }
    })
  },
  components: {
    'v-header': Header,
    'v-tab': Tab
  }

}
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import "./common/stylus/mixin.styl"

  .tab
    display: flex
    width: 100%
    height: 40px
    line-height: 40px
    // border-bottom: 1px solid rgba(7, 17, 27, 0.1)
    border-1px(rgba(7, 17, 27, 0.1))
    .tab-item
      flex: 1
      text-align: center
      & > a
        display: block
        font-size: 14px
        color: rgb(77, 85, 93)

  .tab .active
    color: #f01414
</style>
